<template>
	<view class="revise">
		<!-- 自定义导航栏 -->
		<u-navbar :is-back="true" title="我的" :background="background" :title-color="black" title-color="#fff"
			:title-size="40" :border-bottom="false" back-icon-color="white"></u-navbar>
		<ul class="reviseList">
			<li>
				<span>旧密码：</span>
				<u-input type="password" placeholder="请输入旧密码" :type="type" :password-icon="passwordIcon"
					:clearable='clearable' v-model="data.old_password" />
			</li>
			<li>
				<span>新密码：</span>
				<u-input type="password" placeholder="请输入旧密码" :type="type" :password-icon="passwordIcon"
					:clearable='clearable' v-model="data.passwordOne" />
			</li>
			<li>
				<span>确认密码：</span>
				<u-input type="password" placeholder="请输入旧密码" :type="type" :password-icon="passwordIcon"
					:clearable='clearable' v-model="data.password" />
			</li>
		</ul>
		<u-button type="primary" class="Btn" plain="true" @click="tijiao()">提交</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundImage: 'linear-gradient(45deg, #9C6CEE, #78AAE8)'
				},
				data: {
					old_password: '', //旧密码
					passwordOne: '',
					password: ''
				},
				type: 'password',
				passwordIcon: true,
				border: true,
				value: '',
				clearable: false,
				codeSrc: ''
			}
		},
		methods: {
			tijiao() {
				let data = this.data
				this.$http(this.$api.password, data).then(res => {
					if (this.data.passwordOne != this.data.password) {
						uni.showToast({
							title: '两次密码不一致！'
						})
					} else if (res.code == 1) {
						uni.showToast({
							title: '密码修改成功!'
						})
						setTimeout(() => {
							uni.reLaunch({
								url: '../index/index'
							})
						}, 1500)
					} else {
						uni.showToast({
							title: '密码修改失败!',
							icon: 'error'
						})
					}
				})
			},
		},
		onLoad() {

		}
	}
</script>

<style>
	.reviseList {
		border-radius: 10px;
		width: 95%;
		margin: 10px auto;
		box-shadow: 1px 0px 5px #B9B9B9;
	}

	.reviseList li {
		display: flex;
		justify-content: left;
		border-bottom: 1px #dfdfdf solid;
		padding: 10px;
	}

	.reviseList li:last-child {
		border: none;
	}

	.reviseList li span {
		text-align-last: justify;
		width: 70px;
		height: 40px;
		line-height: 40px;
		font-size: 14px;
	}

	.reviseList li input {
		font-size: 30rpx;
		width: 470rpx;
		height: 80rpx;
	}

	ul {
		margin-bottom: 50rpx;
	}

	.Btn {
		width: 350rpx;
		margin-bottom: 700rpx;
		display: block;
		margin: 200rpx auto;
	}

	.input {
		height: 80rpx;
		text-align: left;
		padding-left: 50rpx;
		border-radius: 50rpx;
		font-size: 30rpx;
		border: 1px solid #CCCCCC;
		color: #fff;
		padding-right: 10px;
		background-color: #e1e1e1;
	}

	.uni-form-item {
		margin: 30rpx 0;
	}
</style>
